# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=watchexec
pkgver=2.1.1
pkgrel=0
pkgdesc="Executes commands in response to file modifications"
url="https://github.com/watchexec/watchexec"
# riscv64: scopes test in ignore/tests/filtering.rs fails
# s390x: nix/libc crate
arch="all !riscv64 !s390x"
license="Apache-2.0"
makedepends="cargo cargo-auditable dbus-dev"
checkdepends="bash"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/watchexec/watchexec/archive/refs/tags/v$pkgver.tar.gz
	system-dbus.patch
	"
options="net"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --all --frozen
}

package() {
	install -Dm755 target/release/watchexec -t "$pkgdir"/usr/bin/
	install -Dm644 doc/watchexec.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 completions/bash \
		"$pkgdir"/usr/share/bash-completion/completions/watchexec
	install -Dm644 completions/fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/watchexec.fish
	install -Dm644 completions/zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_watchexec
}

sha512sums="
7d84398c53140b45466bb95e8e32dc352535de5da9f0037d1b242b70142b8185775cb38687f9ca29c749c075ed3c22b6e77fd0b1f84973103b40347aa7669c13  watchexec-2.1.1.tar.gz
9827cde53207fc20ab7a6e971e952e9c3c9cab7b2d1714ca3816a4468e9dd3bba4281a4fbaa3d46cc8e53db52d21226072c615750e72f590cf76e69863e14266  system-dbus.patch
"
